package com.kingyun.gpsinspection.purificationservice.facade.service.som;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.RedisValue;
import com.kingyun.gpsinspection.purificationservice.facade.model.som.FacadeDataItem;
import com.kingyun.gpsinspection.purificationservice.facade.model.som.FacadeFatherItem;
import com.kingyun.gpsinspection.purificationservice.facade.model.som.FacadeStep;
import com.kingyun.gpsinspection.purificationservice.facade.model.som.FacadeWorkOrder;

import java.math.BigDecimal;
import java.util.List;

/**
 * 平板端工单相关service
 * Created by yangcs on 2017/2/20.
 */
public interface FacadeWorkOrderService {

    /**
     * 根据cellId查询表单表单项
     *
     * @param cellId
     * @return
     */
    List<FacadeFatherItem> getItemsByCellId(String cellId, BigDecimal stepVersion);

    /**
     * 根据cellId查询步骤(包含结果)
     *
     * @param cellId
     * @param stepVersion
     * @param cellResultId
     * @return
     */
    List<FacadeStep> getStepsByCellId(String cellId, BigDecimal stepVersion, String cellResultId);

    /**
     * 巡回检查时自定义步骤
     *
     * @param workOrderId
     * @param cellResultId
     * @return
     */
    List<FacadeStep> getStepNoCellId(String workOrderId, String cellResultId);

    List<FacadeStep> getStepNoCellIdByCategory(String workOrderId);

    List<FacadeStep> getStepNoCellIdByCategory(String workOrderId, String cellResultId);

    /**
     * 根据表单项Id查询数据项
     *
     * @param fatherId
     * @param cellResuleId
     * @return
     */
    List<FacadeDataItem> getDataItemsByFatherId(String fatherId, String cellResuleId);

    /**
     * 根据步骤Id查询数据项
     *
     * @param stepId
     * @param stepResultId
     * @return
     */
    List<FacadeDataItem> getDataItemsByStepId(String stepId, String stepResultId);

    /**
     * 同步工单
     *
     * @param userId     用户id
     * @param updateTime 更新时间戳
     * @param status     0全部，1今日，2遗留
     * @return
     */
    List<FacadeWorkOrder> getOrders(String userId, long updateTime, int status);

    /**
     * 获取工单台帐
     *
     * @param userId
     * @return
     */
    JSONObject getWeekAndMouth(String userId, Integer limit, Integer offset);

    /**
     * 获取待办工单数量
     *
     * @param userId
     * @param updateTime
     * @return
     */
    int getDeal(String userId, long updateTime);

    /**
     * 查询工单信息
     *
     * @param workOrderId
     * @return
     */
    FacadeWorkOrder getOrderById(String workOrderId);

    /**
     * 构造工单信息
     *
     * @param order
     * @return
     */
    FacadeWorkOrder createWorkOrder(FacadeWorkOrder order);

    /**
     * 获取工单
     *
     * @param workOrderId
     * @return
     */
    FacadeWorkOrder getOrder(String workOrderId);

    /**
     * 首页工单统计
     *
     * @return
     */
    JSONArray getOrderCount(RedisValue redisValue);

    /**
     * 未超期未完成的工单总数
     *
     * @param redisValue
     * @return
     */
    int getUnFinishOrder(RedisValue redisValue);

    /**
     * 获取终止任务关联的工单
     *
     * @param userId
     * @param updateTime
     * @return
     */
    List<String> getInvalid(String userId, long updateTime);
}
